package eabnp.eflow.api.impl;

import java.rmi.RemoteException;

import org.springframework.remoting.rmi.RmiProxyFactoryBean;

import com.suredy.flow.IFlowRmiSrv;

import eabnp.eflow.api.TodoItemInfo;
import eabnp.eflow.info.ctrlinfo.processctrl.actresult.ActResultListCtrl;

public class AppRmiAgent {

	protected IFlowRmiSrv getAppClient() {
		IFlowRmiSrv client = null;
		try {
			RmiProxyFactoryBean factory= new RmiProxyFactoryBean(); 
			 factory.setServiceInterface(IFlowRmiSrv.class);
			 factory.setServiceUrl("rmi://127.0.0.1:8008/apprmi");
			 factory.setCacheStub(false);
			 factory.setLookupStubOnStartup(true);
			 factory.afterPropertiesSet();
			client = (IFlowRmiSrv) factory.getObject();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return client;
	}

	public TodoItemInfo setTodo(TodoItemInfo info,String fileType,String fileId) {
		try {
			return this.getAppClient().SetTodeInfo(info, fileType, fileId);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public void setAcc(ActResultListCtrl actRsCtrl) {
		try {
			this.getAppClient().actRsProcess(actRsCtrl);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
}
